<include file="header" />
<body>
<div class="wraper">
    <div class="load" style="display:none;">
        <img class="load-bee" src="/assets/base/repair/images/load-bee.png"/>
    </div>
    <div class="head clearfix">
        <a href="javascript:history.back();" class="iconfont icon-zuo pull-left"></a>
        <span class="head-name pull-left">{BEESCRM:$app_name}</span>
        <a href="{BEESCRM::U('/Base/Laundrynew/index',array('laundryId'=>$laundryId))}" class="iconfont icon-shouye pull-left text-right"></a>
    </div>
    <div class="title padding tb-mode">
        <p class="tb-cell">当前选中：{BEESCRM:$websiteInfo['website_name']}|{BEESCRM:$terminalInfo['line_num']}号洗衣机</p>
    </div>
    <div class="lists">
        <div class="list-line tb-mode">
            <p class="tb-cell">剩余金额 <span class="text-20 text-green"><if condition="$terminalInfo['fees'] eq 1">免费使用<else/>{BEESCRM:$overplus_time}元</if></span></p>
            <p class="tb-cell text-right"><a href="/index.php?g=Base&m=LaundrynewReCharging&a=chargingRecharge&laundryId={BEESCRM:$laundryId}" class="charge-btn">充值</a></p>
        </div>
        <!-- <div class="list-line">
            <p class="padding-bottom">请选择使用时长</p>
            <div class="time-box clearfix">
                <volist name="kitchenExchange" id="vo">
                    <div class="time-list padding-10">{BEESCRM:$vo['value']/60}小时</div>
                </volist>
            </div>
        </div> -->

    </div>

    <notempty name="chargingTips">
        <div class="title padding tb-mode">
            <p class="tb-cell">说明</p>
        </div>
        <div class="lists text-12">
            {BEESCRM:$chargingTips}
        </div>
    </notempty>

    <div class="btn-box">
        <a href="javascript:" class="btn submit">立即使用</a>
    </div>

    <!--<div class="padding tb-mode">
        <p class="text-center text-grey text-12">温馨提示：点击立即充电即代表您已同意<span class="text-green">《用户协议》</span></p>
    </div>-->

</div>
<input type="hidden" name="surplusTime" id="surplusTime" value="{BEESCRM:$overplus_time}" />
<input type="hidden" name="terminalId" id="terminalId" value="{BEESCRM:$terminalId}" />
<input type="hidden" name="protocol" id="protocol" value="{BEESCRM:$protocol}" />
<include file="commonJS"/>
<include file="errorreport" />
<script>
    seajs.use('$', function(main) {
        if($(document).height()>$(window).height()){
            $('.btn-box').addClass('fixed-btn');
            $('.wraper').css('paddingBottom',50);
        }else{
            $('.btn-box').removeClass('fixed-btn');
        }


        $(function(){

            $(document).on('click','.submit',function(){
                var data={};
                var overplus_time=parseInt("{BEESCRM:$remainTime}");
                var fees=parseInt("{BEESCRM:$websiteInfo['fees']}");
                data.fees=fees;
                data.terminal_id=parseInt("{BEESCRM:$terminalInfo['terminal_id']}");
                data.website_id=parseInt("{BEESCRM:$websiteInfo['website_id']}");

                if(!data.terminal_id || !data.website_id){
                    fm.alert('参数错误');return;
                }

                $.ajax({
                    url:"{BEESCRM::U('/Base/Laundrynew/chargeAjax',array('laundryId'=>$laundryId))}",
                    type:"post",
                    data:data,
                    dataType:"json",
                    beforeSend: function(){
                        fm.showLoging('通电检测中...');
                    },
                    success:function(res){
                        fm.closeLayer();
                        if(res.status == 'S'){
                            reload(res.id);
                        }else{
                            fm.alert(res.message,'',3);
                        }

                    },
                    error:function(res){
                        fm.closeLayer();
                        fm.alert(res.message,'',3)
                    }
                })

            });
            //刷新页面
            function reload(id){
                setTimeout('location.href="{BEESCRM::U('/Base/Laundrynew/charging',array('laundryId'=>$laundryId,'hideNav' => 1))}/id/'+id+'"',100);
            }

            $('.tab-prize').on('click','.option',function(){
                if($(this).hasClass('other')){
                    $(this).siblings().removeClass('checked');
                    $('#amount').change(function(){
                        var num=Number($(this).val());
                        if(num!=0){
                            $('#hour').text(num);
                            $('#minute').val(num*60);
                        }
                    })

                }
                else{
                    if(!$(this).hasClass('checked')){
                        $(this).toggleClass('checked').siblings().removeClass('checked');
                    }
                    $('#amount').val(0);
                    var num=Number($(this).data('amount'));
                    $('#hour').text(num);
                    $('#minute').val(num*60);

                }
            })

        });
    });


</script>
</body>
</html>